package com.wss.day06.time;

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.TimeUnit;

/**
 * @author wangshaoshuai
 * @desc TODO
 * @date 2025/4/25
 */
public class Test01 {
    public static void main(String[] args) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

        Date date1 = sdf.parse("2014-05-25");
        Date date2 = sdf.parse("2012-12-28");

        long diffInMillies = Math.abs(date1.getTime() - date2.getTime());
        long diff = TimeUnit.DAYS.convert(diffInMillies, TimeUnit.MILLISECONDS);

        System.out.println("天数差: " + diff + " 天");




        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss EEEE");

        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_YEAR, 500);

        Date futureDate = calendar.getTime();

        System.out.println("500天后的日期和时间: " + sdf1.format(futureDate));


        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat sdfDay = new SimpleDateFormat("EEEE");

        Date birthDate = sdf2.parse("2004-03-18");

        System.out.println("出生当天是: " + sdfDay.format(birthDate));
    }
}
